package com.vajava.str.model;

import org.apache.commons.lang.builder.ToStringBuilder;

import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;

@Entity(name = "TestType")
public class TestType {
    private Long id;
    private String name;
    private RunnerType runner;

    public TestType(String name, RunnerType runner) {
        this.name = name;
        this.runner = runner;
    }

    protected TestType() {
    }

    @Id
    @GeneratedValue
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Enumerated(EnumType.STRING)
    public RunnerType getRunner() {
        return runner;
    }

    public void setRunner(RunnerType runnerType) {
        this.runner = runnerType;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        TestType testType = (TestType) o;

        if (!name.equals(testType.name)) return false;
        if (runner != testType.runner) return false;

        return true;
    }

    public int hashCode() {
        int result;
        result = name.hashCode();
        result = 31 * result + runner.hashCode();
        return result;
    }

    public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }
}
